Whenever you write an Effect, consider whether it would be clearer to wrap it in a custom Hook.
We shouldn’t need Effects very often, but only when we need to “step outside React” to synchronise with some external system or to do something React doesn’t have a built-in API for.
With time, the React team’s goal is to reduce the number of Effects in your app to the minimum by providing more specific solutions to more specific problems. Wrapping your Effects in custom Hooks makes it easier to upgrade your code when these solutions become available.